import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig(({ command, mode }) => {
   const env = loadEnv(mode, process.cwd())
   return {
      plugins: [vue()],
      base: command == 'build' ? '/' : '/',
      server: {
         host: true,
         proxy: {
            '/api': {
               target: env.VITE_API_URL,
               changeOrigin: true
            },
            '/uploads': {
               target: env.VITE_API_URL,
               changeOrigin: true
            }
         },
         port: 5174
      }
   }
})
